package main

import (
	"net/http"

	"time"
)

var VERSION = "0.0.4"

func main() {
	defer time.Sleep(1 * time.Second)

	loadConfig()

	setLogger()

	lg.Debug("config is %+v", cfg)

	serverMux := http.NewServeMux()
	for projName, projSetting := range cfg.Supervisor {
		lg.Debug("Set route /%v", projName)

		serverMux.HandleFunc("/"+projName,
			handleFunc(projName, projSetting))
	}

	lg.Info("Start Server @ %v", cfg.Server.Addr)
	err := http.ListenAndServe(cfg.Server.Addr, serverMux)
	if err != nil {
		lg.Critical("Server panic with error: %v", err)
	}

}
